Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
Direct path "alternative" for offsite html loading via JS

Currently, my approach (thanks to so user help) is to load a offsite html into the current page via:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>   
<script type="text/javascript">
$(document).ready(function(){
    $("#output").load("https://homepageforme.com/pathtofile/Search.html");
});
</script>
    <div class="formClass">
        <div id="output">
        </div>

The only gripe I have here, is that this requires me to specifiy a full "url".

F.e. In iframes I could simply state "Search.html" (similar to a href), but here this won't work.

If there is no other workaround, I'd be ok with "taking the current window url" (window location) (sans the final file of the current page) => https://homepageforme.com/pathtofile/

then adding the fileanme "Search.html"

getting "https://homepageforme.com/pathtofile/Search.html"

that way and being able to feed it to the JS like this.

The reason being, that if I want to migrate the website, I'm forced to edit the paths manually.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

So you want the URL without the last part (/*.html), then, it's :

window.location.href.match(/(.*)[\/\\]/)[1]

Then, it becomes:

var baseUrl = window.location.href.match(/(.*)[\/\\]/)[1];
$("#output").load(baseUrl + "/Search.html");

NOTE - If you just want to reuse the origin (http://example.com), then use window.location.origin

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda